﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TinyEngine.Core.Parsers;
using Microsoft.Xna.Framework;

namespace TinyEngine.Core.Entities.Parsers
{
    public class NullParser : IEntityParser
    {
        public System.Xml.Linq.XElement ToXmlElement(IEntity obj)
        {
            var root = new System.Xml.Linq.XElement(obj.GetType().Name);
            root.SetAttributeValue("Name", obj.Name);
            if (obj.Position != Vector3.Zero)
            {
                root.SetAttributeValue("Position", ParserHelper.VectorToString(obj.Position));
            }
            return root;
        }

        public IEntity FromXmlElement(System.Xml.Linq.XElement element)
        {
            var nl = new NullEntity();
            nl.Name = element.Attribute("Name").Value;
            nl.Position = ParserHelper.TryParseVector3("Position", element);
            return nl;
        }
    }
}
